#pragma once
#include "RBTree.h"


namespace Set
{
	template<class K>
	class set
	{
		struct SetOfT
		{
			K operator()(const K& key)
			{
				return key;
			}
		};

	public:
		typedef typename wjh::RBTree<K,  K, SetOfT>::const_iterator iterator;
		typedef typename wjh::RBTree<K, K, SetOfT>::const_iterator const_iterator;


		bool insert(const K& key)
		{
			return _t.insert(key);
		}

		iterator begin()
		{
			return _t.begin();
		}

		iterator end()
		{
			return _t.end();
		}

	private:
		wjh::RBTree<K,  K, SetOfT> _t;
	};

	void Test_Set1()
	{
		set<int> s;
		int a[] = { 16, 3, 7, 11, 9, 26, 18, 14, 15 };
		//int a[] = { 4, 2, 6, 1, 3, 5, 15, 7, 16, 14 };
		for (auto e : a)
		{
			s.insert(e);
		}

		set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			std::cout << *it << " ";
			++it;
		}

		std::cout << std::endl;

		for (auto e : s)
		{
			std::cout << e << " ";
		}

		std::cout << std::endl;
	}
}
